package com.yexs.services.impl;

import com.yexs.dao.impl.mapper.AccountMapper2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AccountService2 {
    @Autowired
    private AccountMapper2 accountMapper2;

    @Transactional
    public void transfer() throws RuntimeException {
        //用户1减10块 用户2加10块
        accountMapper2.update(90, 1);
        System.out.println("=======测试事物方法=------------");
        //int i = 1 / 0;//故意报错，看是否会回滚
        accountMapper2.update(110, 2);
    }
}
